package com.muyu.system.controller;



import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.system.domain.DanmoVipPerson;
import com.muyu.system.service.IDanmoVipPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * vip人员Controller
 * 
 * @author yl
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/person")
public class DanmoVipPersonController extends BaseController
{
    @Autowired
    private IDanmoVipPersonService danmoVipPersonService;


    /**
     * 查询vip人员列表
     */
//    @RequiresPermissions("system:person:list")
    @PostMapping("/list")
    public Result<PageInfo<DanmoVipPerson>> list(@RequestBody DanmoVipPerson danmoVipPerson)
    {
        PageHelper.startPage(danmoVipPerson.getPageNum(), danmoVipPerson.getPageSize());
        List<DanmoVipPerson> list = danmoVipPersonService.selectDanmoVipPersonList(danmoVipPerson);
        PageInfo<DanmoVipPerson> danmoArtCollegesPageInfo = new PageInfo<>(list);
        return Result.success(danmoArtCollegesPageInfo);
    }

    /**
     * 导出vip人员列表
     */
//    @RequiresPermissions("system:person:export")
    @Log(title = "vip人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoVipPerson danmoVipPerson)
    {
        List<DanmoVipPerson> list = danmoVipPersonService.selectDanmoVipPersonList(danmoVipPerson);
        ExcelUtil<DanmoVipPerson> util = new ExcelUtil<DanmoVipPerson>(DanmoVipPerson.class);
        util.exportExcel(response, list, "vip人员数据");
    }

    /**
     * 获取vip人员详细信息
     */
//    @RequiresPermissions("system:person:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoVipPersonService.selectDanmoVipPersonById(id));
    }

    /**
     * 新增vip人员
     */
//    @RequiresPermissions("system:person:add")
    @Log(title = "vip人员", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result add(@RequestBody DanmoVipPerson danmoVipPerson)
    {
        return danmoVipPersonService.insertDanmoVipPerson(danmoVipPerson);
    }

    /**
     * 修改vip人员
     */
//    @RequiresPermissions("system:person:edit")
    @Log(title = "vip人员", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public Result edit(@RequestBody DanmoVipPerson danmoVipPerson)
    {
        return danmoVipPersonService.updateDanmoVipPerson(danmoVipPerson);
    }

    /**
     * 删除vip人员
     */
//    @RequiresPermissions("system:person:remove")
    @Log(title = "vip人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoVipPersonService.deleteDanmoVipPersonByIds(ids));
    }

    /**
     * 个人的
     */
    @PostMapping("/person")
    public DanmoVipPerson person(@RequestBody DanmoVipPerson danmoVipPerson)
        {
            return danmoVipPersonService.selectDanmoVipPerson(danmoVipPerson);
        }

    /**
     * 自己的
     * @param
     * @return
     */
    @PostMapping("/getInfo")
    public DanmoVipPerson getInfo()
        {
            LoginUser loginUser = SecurityUtils.getLoginUser();
            Long userid = loginUser.getUserid();
            DanmoVipPerson danmoVipPerson = new DanmoVipPerson();
            danmoVipPerson.setUserId(userid);
            return danmoVipPersonService.selectDanmoVipPerson(danmoVipPerson);
        }


}
